extends Node
const BUFFER_DURATIO= 5
var input_buffer = {}

func _ready() -> void:
	set_process(true)
	
func _process(delta: float) -> void:
	for action in input_buffer.keys().duplicate():
		input_buffer[action] -= 1
		if input_buffer[action] <= 0:
			input_buffer.erase(action)

func buffer_input(action:String):
	input_buffer[action] = BUFFER_DURATIO
	
func has_buffered_input(action:String) -> bool:
	return action in input_buffer
	
func consume_buffered_input(action:String) -> bool:
	if has_buffered_input(action):
		input_buffer.erase(action)
		return true
	return false
	
